cmake_minimum_required(VERSION 2.8.3)
project(costmap_2d)

find_package(catkin REQUIRED
        COMPONENTS
            cmake_modules
            dynamic_reconfigure
            geometry_msgs
            laser_geometry
            map_msgs
            message_filters
            message_generation
            nav_msgs
            pluginlib
            roscpp
            sensor_msgs
            std_msgs
            tf2
            tf2_geometry_msgs
            tf2_ros
            tf2_sensor_msgs
            visualization_msgs
            voxel_grid
            pcl_conversions
            pcl_ros
        )

find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread)
# set(yaml-cpp_DIRS /home/yinantu/nav_noros_ws/src/yaml-cpp-release-0.5.1/build)
# set(MyReader_DIRS /home/yinantu/nav_noros_ws/tmp/config_test/build)


# find_package(MyReader REQUIRED)
# message(STATUS ===${MyReader_INCLUDE_DIR})
# message(STATUS ===${MyReader_CMAKE_DIR})
# message(STATUS ===${MyReader_LIBRARIES})

include_directories(
    include
    ${catkin_INCLUDE_DIRS}
    ${EIGEN3_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
    # ${MyReader_INCLUDE_DIR}
)

add_definitions(${EIGEN3_DEFINITIONS})

catkin_package(
    INCLUDE_DIRS
        include
        ${EIGEN3_INCLUDE_DIRS}
    LIBRARIES costmap_2d layers
    CATKIN_DEPENDS
        dynamic_reconfigure
        geometry_msgs
        laser_geometry
        map_msgs
        message_filters
        message_runtime
        nav_msgs
        pluginlib
        roscpp
        sensor_msgs
        std_msgs
        tf2_ros
        visualization_msgs
        voxel_grid
    DEPENDS
        EIGEN3
        Boost
)
add_library(my_reader
  src/config_file.cpp
)
add_dependencies(my_reader ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(my_reader
  ${Boost_LIBRARIES}
  ${catkin_LIBRARIES}
  # ${MyReader_INCLUDE_DIR}
)

add_library(data_collector
  src/data_collector.cpp
)
add_dependencies(data_collector ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(data_collector
  ${Boost_LIBRARIES}
  ${catkin_LIBRARIES}
  # ${MyReader_INCLUDE_DIR}
)

add_library(layers
  src/inflation_layer.cpp
  src/obstacle_layer.cpp
  src/static_layer.cpp
  src/observation_buffer.cpp
  src/layer.cpp
  src/layered_costmap.cpp
)
add_dependencies(layers ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(layers
  data_collector
  my_reader
)

add_library(costmap_2d
  src/costmap_2d.cpp
  src/costmap_2d_ros.cpp
  src/costmap_2d_publisher.cpp
  src/costmap_math.cpp
  src/footprint.cpp
  src/costmap_layer.cpp
)
add_dependencies(costmap_2d ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(costmap_2d
  layers
  ${Boost_LIBRARIES}
  ${catkin_LIBRARIES}
  # ${MyReader_INCLUDE_DIR}
)
add_executable(costmap_2d_node src/costmap_2d_node.cpp)
add_dependencies(costmap_2d_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(costmap_2d_node
    layers
    costmap_2d
    # data_collector
    # my_reader
    # layers
    ${Boost_LIBRARIES}
    ${catkin_LIBRARIES}
)

MESSAGE(STATUS "${CATKIN_PACKAGE_SHARE_DESTINATION}")

